/*
 * tcp_ip_client.h
 *
 *  Created on: Aug 20, 2012
 *      Author: drew
 */

#ifndef TCP_IP_CLIENT_H_
#define TCP_IP_CLIENT_H_

#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <pthread.h>

typedef void (*vpTcpIpClientRxCallback)(char * cRxBuff, int iLength);

typedef struct
{
  struct sockaddr_in      xServerAddress;
  struct hostent   *      xpHost;
  int                     iSocket;
  char                    cpHostAddress[32];
  int                     iPort;
  vpTcpIpClientRxCallback vpCallback;
  pthread_t               xThreadHandle;
} xTcpIpClientDescription, * xpTcpIpClientDescription, * TcpIpClientObject;

xpTcpIpClientDescription xpTcpIpClientCreateObject( char * cpAddress, int iPort, vpTcpIpClientRxCallback vpCallback );
void vTcpIpClientDestroyObject( xpTcpIpClientDescription xpTcpIpClientObject );
int iTcpIpClientInitialize( xpTcpIpClientDescription xpTcpIpClientObject );
void vTcpIpClientCleanup( xpTcpIpClientDescription xpTcpIpClientObject );
int iTcpIpClientPrint( xpTcpIpClientDescription xpTcpIpClientObject, char * cpBuff, int iLength );

#endif /* TCP_IP_CLIENT_H_ */
